import React from 'react';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import { List, Icon } from 'antd-mobile';
import content from '../../../common/contentCss/content.css';
import CustTitle from '../../../common/title/title';
import MyWalletView from './pages/myWallet';


function MyWallet({dispatch,loading,myWallet}) {
  const { selectedIndex, billNavIndex,
    incomeDetailList, payDetailList, myBalanceInfo } = myWallet;
  const titleProps = {
    titleName:'我的钱包',
    showSaveBtnStatus: true,
    saveBtnName: '',//设置
    goBack(){
      dispatch(routerRedux.goBack());
    },
    onSave(){
      // console.log('我的钱包----设置')
      // dispatch(routerRedux.push({
      //   pathname: '/set-my-wallet',
      // }));
    },
  }

  const myWalletProps = {
    selectedIndex,
    billNavIndex,
    myBalanceInfo,
    incomeDetailList,
    payDetailList,
    onSelected(selectedIndex){
      let url = 'getIncomeDetail';
      dispatch({
        type:'myWallet/querySuccess',
        payload:{
          selectedIndex,
          incomeDetailList:[],
          payDetailList:[],
        }
      })
      dispatch({
        type: `myWallet/${url}`,
        payload:{
        }
      })
    },
    onbillNav(billNavIndex) {

      let url = '';
      if(billNavIndex == 0){
        url = 'getIncomeDetail';
      }else if(billNavIndex == 1){
        url = 'getPayDetail';
      }
      dispatch({
        type:'myWallet/querySuccess',
        payload:{
          billNavIndex
        }
      })
      dispatch({
        type: `myWallet/${url}`,
        payload:{
        }
      })
    },
    onCash(){
      console.log('提现');
      dispatch({
        type:'withdrawCash/querySuccess',
        payload:{
          cash:myBalanceInfo
        }
      })
      dispatch(routerRedux.push({
        pathname:'/withdraw-cash',
        query:{
        }
      }))
    }
  }

  const MarginHeight = () => <div style={{height: '0.6em', backgroundColor:'#F5F5F9'}}></div>;

  return(
    <div className={content.content}>
      <CustTitle {...titleProps}/>
      <div style={{
        marginTop: '2.8125em',
      }}>
      </div>
      <MyWalletView {...myWalletProps}/>
    </div>
  )
}

function mapStateToProps(state, ownProps) {
  return {
    myWallet:state.myWallet,
  }
}

export default connect(mapStateToProps)(MyWallet);
